package com.yonyou.pmclouds.workconnect.process;

import com.alibaba.druid.util.StringUtils;
import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.consts.BillTypeConst;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.workConnect.entity.WorkConBillStatus;
import com.yonyou.pmclouds.workConnect.entity.WorkConnectVO;
import org.apache.commons.lang3.ArrayUtils;

/**
 * 工作联系单新增业务逻辑判断
 * @author fangpengc
 *
 */
public class WorkConnectBeforeAddProcess implements SingleProcessor<WorkConnectVO> {

    @Override
    public void process(WorkConnectVO vo, WorkConnectVO orig) throws BusinessException {
        if(vo == null) {
            throw new BusinessException("需要新增的数据为空");
        } else if (ArrayUtils.isEmpty(vo.getPkReceivers())) {
            throw new BusinessException("接收人为空");
        } else if(StringUtils.isEmpty(vo.getTitle())) {
            throw new BusinessException("主题为空");
        } else if(StringUtils.isEmpty(vo.getPk_contacttype())) {
            throw new BusinessException("联系类型为空");
        }
        // 新增单据默认待接收态
        vo.setBillstatus(WorkConBillStatus.STATUS_ACCEPTING);
        // 设置单据类型
        vo.setBill_type(BillTypeConst.WORKCONNECT_BILLTYPE);
    }

}
